<?php

namespace App\Http\Controllers\Db;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;
class DbController extends Controller
{
    public function add(){
        $row = ['name'=>'lee', 'tittle'=>'test', 'content'=>'this is a test'];
        if($id = DB::table('user')->insertGetId($row)){
            return $id;
        }else{
            return 'fail';
        }
        // $id = DB::table('user')->insertGetId($row);
        // var_dump($id);
    }

    public function addGroup(){
        $arr = [
            ['name'=>'lee', 'tittle'=>'add more', 'content'=>'try to add a group data'],
            ['name'=>'lee', 'tittle'=>'undefined', 'content'=>'no thing'],
            ['name'=>'lee', 'tittle'=>'undefined', 'content'=>'no thing'],
        ];
        if($id = DB::table('user')->insertGetId($arr)){
            return $id;
        }else{
            return 'fail';
        }

    }

    public function get(){
        print_r(DB::table('user')->get());
    }
}
